package com.tianhui.consignortwofei.other.auth.recognition.process;

import com.tianhui.consignortwofei.mvp.model.enty.RecognitionInfo;
import com.tianhui.consignortwofei.mvp.model.enty.SelectPhotoInfo;
import com.tianhui.consignortwofei.mvp.model.enty.authLicense.DriverLicenseInfo;
import com.tianhui.consignortwofei.mvp.model.enty.ocrResult.driverLicense.DriverLicenseResult;
import com.tianhui.consignortwofei.other.auth.inte.ProcessCallback;
import com.tianhui.consignortwofei.other.auth.recognition.recognitionResultProcess.DriverLicenseOcrResultProcess;

/**
 * @author fgs
 * @date 2021/5/13
 * @description
 **/
public class DriverLicenseRecognitionProcess implements IRecognitionProcess<DriverLicenseResult, DriverLicenseInfo> {

    @Override
    public void recognitionProcess(RecognitionInfo<DriverLicenseResult> recognitionInfo, SelectPhotoInfo selectPhotoInfo, ProcessCallback<DriverLicenseInfo> processCallback) {
        String errorMessage = "不是驾驶证或图片太模糊，请重新上传";
        DriverLicenseResult result = recognitionInfo.info;
        if (result != null) {
            DriverLicenseOcrResultProcess driverLicenseOcrResultProcess = new DriverLicenseOcrResultProcess();
            DriverLicenseInfo driverLicenseInfo = driverLicenseOcrResultProcess.getDriverOcrResult(result);
            driverLicenseInfo.path = selectPhotoInfo.filePath;

//            if (TextUtils.isEmpty(driverLicenseInfo.name)) {
//                ToastUtil.showShortToast(errorMessage);
//                processCallback.processFailed();
//            } else {
            processCallback.processSuccess(driverLicenseInfo);
//            }

        } else {
            processCallback.processSuccess(null);
//            ToastUtil.showShortToast(errorMessage);
//            processCallback.processFailed();
        }

    }

}
